import Page
from Page import Xting
from Base.Base import Base
from selenium.webdriver.common.by import By


class XtingCategoryPage(Base):
    """
    想听-分类页面
    """

    def __init__(self, driver):
        Base.__init__(self, driver)
        
        # 专辑分类tab
        self.category_album_text = (By.XPATH, Page.TEXT.format("专辑分类"))

        # 电台分类tab
        self.category_radio_text = (By.XPATH, Page.TEXT.format("电台分类"))
        
        # 列表标签标题, 默认选择第1个, 取值范围[1,10]
        self.category_list_tag_title_text = (By.XPATH, Xting.category_list_tag_title_text.format(1))

    def get_list_tag_text(self, index=1):
        """
        获取排行榜页面的指定索引的标签

        :param index: 标签的索引, 取值范围: 1~10
        :return: 元素对象
        """

        self.category_list_tag_title_text = (By.XPATH, Xting.category_list_tag_title_text.format(index))

        return self.find_element_o(self.category_list_tag_title_text)

    def click_list_tag_text(self, index=1):
        """
        点击排行榜页面的指定索引的标签

        :param index: 标签的索引, 取值范围: 1~10
        :return: None
        """
        self.category_list_tag_title_text = (By.XPATH, Xting.category_list_tag_title_text.format(index))

        self.click_element(self.category_list_tag_title_text)

    def click_album(self):
        """
        点击`专辑分类`tab

        :return:
        """
        self.click_element(self.category_album_text)

    def click_radio(self):
        """
        点击`电台分类`tab

        :return:
        """
        self.click_element(self.category_radio_text)


if __name__ == '__main__':
    pass
